import request from './request';

/**
 * 获取 JSSDK 配置
 * @param {object} params - 请求参数
 * @param {string} params.url - 当前页面的 URL
 */
export const getJssdkConfig = (params) => {
  return request.post('/wechat/jssdk-config', params);
};

/**
 * 创建预支付订单
 * @param {object} params - 请求参数
 * @param {string} params.openid - 用户的 openid
 */
/**
 * 创建订单
 * @param {{planCode: string, userId: number | bigint}} params
 */
export const createOrder = (params) => {
  return request.post('/order/create', params);
};

/**
 * 调用模拟登录接口
 */
export const mockLogin = () => {
  return request.get('/mock/login');
};

/**
 * 发起支付
 * @param {{orderId: number | bigint}} params
 */
export const payOrder = (params) => {
  return request.post('/order/pay', params);
};

// 如果有其他接口，可以继续在这里添加
// 动态/消息流相关接口
/**
 * 发布动态
 * @param {{userId: number, content: string, imageUrl: string}} params
 */
export const publishDynamic = (params) => {
  return request.post('/feed/publish', params);
};

/**
 * 动态列表
 * @param {{page?: number, pageSize?: number, userId?: number}} params
 */
export const listDynamics = (params) => {
  return request.get('/feed/list', { params });
};

/**
 * 阅读+1
 * @param {{id: number}} params
 */
export const readDynamic = (params) => {
  return request.post('/feed/read', params);
};
